
// TODO: TCC_LIBTCC1 use libtcc.lib on windows
static CONFIG_H: &str = r#"
#define TCC_VERSION "0.9.27"
#define TCC_LIBTCC1 "msvcrt"
"#;

fn main() {
    std::fs::write("tinycc/config.h", CONFIG_H).unwrap();
    let mut builder = cc::Build::new();
    let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
    let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
    builder.define("ONE_SOURCE", "1");
    if target_os == "windows" {
        builder.define("TCC_TARGET_PE", None).flag("/utf-8");
    }
    if target_arch == "aarch64" {
        builder.define("TCC_TARGET_ARM64", "1");
    }
    if target_arch == "x86_64" {
        builder.define("TCC_TARGET_X86_64", None);
    }
    println!("cargo:rustc-link-lib=static=tcc");
    builder.file("tinycc/libtcc.c").compile("tcc");
}